package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqjob.PyqJobDto;
import com.uzai.console.dto.pyq.pyqjob.PyqJobIdDto;
import com.uzai.console.dto.pyq.pyqjob.PyqJobQuery;
import com.uzai.console.dto.pyq.pyqjobdetail.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.pyq.PyqJobDetailService;
import com.uzai.console.service.pyq.PyqJobService;
import com.uzai.console.vo.pyq.pyqjob.PyqJobVo;
import com.uzai.console.vo.pyq.pyqjobdetail.PyqJobDetailVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 朋友圈详情明细
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "朋友圈详情明细",tags = "个人微信|朋友圈|朋友圈详情明细")
@ApiSort(33)
@RestController
public class PyqJobDetailController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqJobDetailController.class);

    @Autowired
    private PyqJobDetailService pyqJobDetailService;

    @ApiOperation(value = "发送详情分页查询列表", notes = "发送详情分页查询列表", response = PyqJobDetailVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqJobDetail/findPyqJobDetailList")
    public Object findPyqJobDetailList(@RequestBody PyqJobDetailQuery pyqJobDetailQuery){
        return pyqJobDetailService.findPyqJobDetailList(pyqJobDetailQuery);
    }

    @ApiOperation(value = "查询发送详情内容", notes = "查询发送详情内容", response = PyqJobDetailVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqJobDetail/findPyqJobDetail")
    public Object findPyqJobDetail(@RequestBody PyqJobDetailIdDto pyqJobDetailIdDto){
        return pyqJobDetailService.findPyqJobDetail(pyqJobDetailIdDto);
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "再发一次", notes = "再发一次")
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqJobDetail/sendBegin")
    public Object sendBegin(@RequestBody PyqJobDetailIdDto pyqJobDetailIdDto){
        pyqJobDetailService.sendBegin(pyqJobDetailIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "删除发送详情微信朋友圈", notes = "删除发送详情微信朋友圈")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqJobDetail/deleteWxPyq")
    public Object deleteWxPyq(@RequestBody PyqJobDetailDeleteDto pyqJobDetailDeleteDto){
        pyqJobDetailService.deleteWxPyq(pyqJobDetailDeleteDto);
        try{
            //延迟1秒
            Thread.sleep(1000);
        }catch (Exception e){
        }
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "立即发送", notes = "立即发送")
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqJobDetail/sendNow")
    public Object sendNow(@RequestBody PyqJobDetailIdDto pyqJobDetailIdDto){
        pyqJobDetailService.sendNow(pyqJobDetailIdDto);
        return true;
    }


    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "批量再发一次", notes = "批量再发一次")
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqJobDetail/batchSendBegin")
    public Object batchSendBegin(@RequestBody PyqJobDetailIdListDto pyqJobDetailIdListDto){
        pyqJobDetailService.batchSendBegin(pyqJobDetailIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "批量删除发送详情微信朋友圈", notes = "批量删除发送详情微信朋友圈")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqJobDetail/batchDeleteWxPyq")
    public Object batchDeleteWxPyq(@RequestBody PyqJobDetailDeleteListDto pyqJobDetailDeleteListDto){
        pyqJobDetailService.batchDeleteWxPyq(pyqJobDetailDeleteListDto);
        try{
            //延迟1秒
            Thread.sleep(1000);
        }catch (Exception e){
        }
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "批量删除朋友圈明细记录", notes = "批量删除朋友圈明细记录")
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqJobDetail/batchDeleteById")
    public Object batchDeleteById(@RequestBody PyqJobDetailIdListDto pyqJobDetailIdListDto){
        pyqJobDetailService.batchDeleteById(pyqJobDetailIdListDto);
        try{
            //延迟1秒
            Thread.sleep(1000);
        }catch (Exception e){
        }
        return true;
    }

}
